// 12math.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <stdio.h>
#define MAX_NUM  1000
void findPrimeAndPrint()
{
	unsigned char sieve[MAX_NUM+1];
	long i, j, k=0;

    for (i=2; i <= MAX_NUM; i++)
	{
        sieve[i] = 1;
	}

    for (i=2; i <= MAX_NUM; i++)
    {	if (sieve[i] == 1)
		{
			k++;
			printf("%ld, ",  i);  
			if (k % 15 == 0)   
			{
				printf("\n");   
				k = 0;
			}

			for (j=i*i; j <= MAX_NUM; j += i)
			{
				sieve[j] = 0;
			}
       }
   }

   printf("\n");   
}

void main()
{
    findPrimeAndPrint();
}
